home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / VideoToolbox.h < prev    next >
Encoding:
Text File  |  1995-04-15  |  41.3 KB  |  1,181 lines  |  [TEXT/MMCC]

  1. /*
  2. VideoToolbox.h
  3. This file contains the necessary prototypes for use of all the VideoToolbox
  4. files except Luminance.c, which has its own header file, Luminance.h, and
  5. GDInfo.c and GDTestClut.c, which use GDInfo.h.
  6.  
  7. Precompilation of this header, producing either VideoToolbox.pre or
  8. VideoToolboxMATLAB.pre, will reduce your compilation time tenfold. See
  9. VideoToolbox.c or VideoToolboxMATLAB.c for instructions.
  10.  
  11. Header files whose precompilation depends on the mc68881 or mc68020 THINK C
  12. compiler options (i.e. math.h and mc68881.h) were omitted from VideoToolbox.h so
  13. that the resulting precompiled header file can be used in projects regardless of
  14. those options. (You’ll want them enabled for speed in your lab, but you’ll
  15. usually want them disabled for portability on the road, e.g. the PowerBook 160
  16. has no floating point unit.) If you change other options that affect the
  17. pre-compilation of the headers (e.g. size of double or size of int) you should
  18. rebuild the precompiled header file, to reflect the new settings.
  19.  
  20. The precompilation _does_ depend on the sizeof(double) and sizeof(int)
  21. because most functions use or return such values and the external interface must
  22. allow the appropriate amount of space. THINK C supports a 12-byte "universal"
  23. format double that works well both with the 68881 fpu (which uses the top two
  24. bytes and the bottom 8 bytes) and with SANE (which uses the bottom 10 bytes).
  25. Thus in THINK C it is easy to mix modules compiled with (e.g. your code) and
  26. without (e.g. the ANSI library) the 68881 option. Unfortunately that excellent
  27. feature is unique to THINK C. In MPW and CodeWarrior C you must use 10-byte
  28. doubles when you use SANE (i.e. don't use the 68881 fpu), so when you use these
  29. compilers you'll need separate pre-compiled headers, with and without the 68881
  30. option, if you want to compile for each environment: to use the 68881 fpu, or
  31. run on machines that lack it.
  32.  
  33. Metrowerks CodeWarrior project names end in "µ", and indicate which cpu they
  34. support by "68k" or "ppc". THINK C projects support only the 68k and have names
  35. ending in "π".
  36.  
  37. My naming convention for pre-compiled headers indicates the size of int, "2i" or
  38. "4i", and, if the 68881 is required, "881". Metrowerks pre-compiled headers
  39. indicate which cpu they support by "68k" or "ppc"; THINK C supports only the
  40. 68k. The THINK C pre-compiled header that I use is "VideoToolbox.pre", which
  41. uses 2-byte ints and "universal" 12-byte doubles that work with or without the
  42. 68881. (The THINK C ANSI library requires 2-byte ints.) The Metrowerks
  43. CodeWarrior C pre-compiled headers that I use are called,
  44. "VideoToolbox.68k.4i.pre", "VideoToolbox.68k.4i.881.pre", and
  45. "VideoToolbox.ppc.pre".
  46.  
  47. MAC_C:
  48.  
  49. The Apple Macintosh header files use some extensions to C that are not part of
  50. Standard C, e.g. "pascal", "short double", enums larger than ints, and function
  51. prototypes that specify absolute addresses. These keywords and constructions
  52. cannot be compiled in Standard C. The macro MAC_C is defined as true, below,
  53. only on Macintosh C compilers that incorporate these extensions, and is false
  54. otherwise. The MAC_C symbol is used to prevent inclusion of all the
  55. Macintosh-dependent header files and prototypes when the compiler doesn't
  56. support them. However, lacking any general test for these extensions, a test
  57. must be added, below, for each new compiler. At present we test for Symantec's
  58. THINK C, Apple's MPW C, and Metrowerks CodeWarrior C.
  59.  
  60. MATLAB:
  61.  
  62. The VideoToolbox sources can be linked to create a stand-alone C application, or
  63. a MATLAB external code resource (a "MEX" file), to be invoked by typing the
  64. function name from within MATLAB. In that case we call the THINK C project a
  65. "MATLAB project". A MATLAB project must #define the symbol MATLAB as true for
  66. every C file, must #include the VideoToolbox.h header at the beginning of every
  67. C file, and must #include MATLABMain.h in the main C file.
  68.  
  69. Don't #define MATLAB within your C file; use the Edit:Options:THINK C:Prefix
  70. window instead. E.g. you could type
  71.     #define MATLAB 1
  72. into the Prefix window, or, more conveniently (because it speeds up your
  73. compilations enormously), type
  74.     #include "VideoToolboxMATLAB.pre"
  75. See VideoToolboxMATLAB.c for instructions.
  76.  
  77. The MATLABMain.h header allocates space for QuickDraw globals for use by THINK C
  78. MATLAB projects. It should be #included in the main C file of each THINK C
  79. MATLAB project, i.e. in the C file that contains "main" or "user_fcn". It must
  80. be included in exactly one source file of each project, as the THINK C Linker
  81. will otherwise complain.
  82.  
  83. dgp & dhb.
  84. Copyright 1989-1994 © Denis G. Pelli
  85.  
  86. HISTORY: (omitting changes documented in C files)
  87. 2/20/93 dhb    Added various commonly used headers.  
  88.             Restructured so that only VideoToolbox.h has to be included,
  89.             whether one is creating stand-alone THINK C or code resources
  90.             to be called by MATLAB. Everything that cares is properly conditioned
  91.             by the symbol MATLAB.
  92. 7/9/93    dgp    Changed our convention for the MATLAB symbol, defining it as
  93.             1 or 0 instead of defining or leaving undefined. The advantage of
  94.             this approach is that "MATLAB" can now be used as an argument in an
  95.             ordinary if statement, which is much more readable than #if.
  96. 8/21/93    dhb    Added undefs in #if MATLAB so that memory allocation goes through THINK C 
  97.             library, not as callback. Callbacks would be OK except that the Mathworks 
  98.             forgot to give us one for realloc. This leads to mixing memory managers
  99.              on the same pointers -- bad bad bad.
  100. 9/2/93    dhb    commented out #include <TranslateLinefeeds.h> since it's
  101.             not presently compatible with MATLAB.
  102. 9/2/93    dgp    Moved the NL and NEWLINE macros from Assign.c into this file.
  103. 9/8/93    dgp    Mention VideoToolbox.c.
  104. 9/11/93    dhb,dgp    Define STDIO_INT and STDIO_DOUBLE.
  105. 9/12/93    dhb    Change STDIO_... to PRINTF_... and SCANF_...
  106.             Insert conditional for MATLAB 3.5 vs. 4.x
  107. 9/14/93    dhb    Conditional for MATLAB changed to make symbol match major version number.
  108.             Removed traces of old trying to force 4 byte ints for MATLAB.
  109. 9/14/93    dgp    Moved up inclusion of QuickDraw.h before MATLAB stuff, since cmex.h
  110.             requires it. Fixed typo, changing "#elseif" to "#elif".
  111. 9/15/93    dgp    Edited the comments above, referring to VideoToolbox.c and the new 
  112.             VideoToolboxMATLAB.c.
  113. 9/16/93    dgp    Added contents of former Assign.h.
  114.             Defined MAC_C so that the VideoToolbox.h header may be used with
  115.             Standard C.
  116. 9/16/93    dhb Removed prototype for obsolete GetDateTimeString.
  117. 10/2/93    dgp    Added #include <Errors.h>.
  118. 12/1/93 dgp Now always write "MATLAB" in all caps, since that's the trademarked name.
  119. 12/16/93 dhb Somewhere things got munged.  Conditional for MATLAB version appeared
  120.            before inclusion of cmex, which won't work.  I fixed the order.
  121. 12/16/93 dhb Commented out inclusion of TranslateLineFeeds.h down below.  This
  122.            generates a link error from MATLAB.
  123. 12/29/93 dgp added #include <Packages.h>
  124. 6/12/94  dgp added definition of Apple's new BlockMoveData, for compatibility with
  125.             Apple's old pre-Universal header files.
  126. 6/12/94    dgp #include Strings.h if Universal header files are used.
  127. 7/28/94 dgp Added test for Metrowerks CodeWarrior C.
  128. 9/2/94    dgp #include MacMemory.h
  129. 9/5/94    dgp changed "int" to "short int" in definitions of PRINTF_INT and SCANF_INT for
  130.             MATLAB 4. This is based on common sense, not testing or detailed knowledge.
  131. 3/31/95    dgp    As a gesture of support for Symantec THINK C 8, now define THINK_C.
  132. */
  133. #pragma once            /*  suppress multiple inclusions of this file */
  134. #ifndef _VIDEOTOOLBOX_    /*  suppress multiple inclusions of this file */
  135. #define _VIDEOTOOLBOX_
  136. /*
  137. Header files that are required for successful compilation of the rest of this
  138. file are marked "required".
  139. */
  140. #if defined(SYMANTEC_C)
  141.     #if !defined(THINK_C)
  142.         #define THINK_C 8
  143.     #endif
  144. #endif
  145. #if THINK_C                /* THINK C */    \
  146.     || applec            /* MPW C, presumably with Mac extensions */\
  147.     || __MWERKS__        /* Metrowerks CodeWarrior C, " */
  148.     #if THINK_C
  149.         #if __option(thinkc)
  150.             #define MAC_C 1        /* allow Macintosh C extensions: "pascal", "short double", etc. */
  151.         #else
  152.             #define MAC_C 0        /* Standard C */
  153.         #endif
  154.     #else
  155.         #define MAC_C 1            /* allow Macintosh C extensions: "pascal", "short double", etc. */
  156.     #endif
  157. #else
  158.     #define MAC_C 0                /* Standard C */
  159. #endif
  160. #ifndef SHORT_DOUBLE_OK
  161.     #if SYMANTEC_C
  162.         /* "short double" not supported by THINK C 8 */
  163.     #else
  164.         #define SHORT_DOUBLE_OK MAC_C    /* "short double" not allowed by Standard C */
  165.     #endif
  166. #endif
  167. #include <stdio.h>            /*  required */
  168. #include <stdlib.h>
  169. #if MAC_C
  170.     #include <Quickdraw.h>    /*  required */
  171. #endif
  172. #ifndef MATLAB
  173.     #define MATLAB 0
  174. #endif
  175. #if MATLAB
  176.     /*
  177.     This must come after stdlib.h, stdio.h, and QuickDraw.h and before everything
  178.     else. If MATLAB is true then we include the header file cmex.h.  Otherwise we
  179.     define the data types that are normally provided by that header, so that code
  180.     that uses these types may be compiled for use in applications.  It must come
  181.     before we test for version 3 or 4.  The version 3 cmex.h does not define the
  182.     symbol mex_h; version 4 does.  This is what we use to figure out which
  183.     version we are compiling for.  Sound complicated?  Sigh!
  184.     */
  185.     
  186.     #include <cmex.h>
  187.     // Test for MATLAB 4 or MATLAB 3, and set symbol appropriately.
  188.     #undef MATLAB
  189.     #ifdef mex_h
  190.         #define MATLAB 4
  191.     #else
  192.         #define MATLAB 3
  193.     #endif
  194.     #ifndef MAC_C
  195.         #error "MATLAB requires the Macintosh extensions to C."
  196.     #endif
  197.  
  198.     // Undefine the macros that override memory allocation.  MATLAB's implementation
  199.     // doesn't work if you use realloc.
  200.     #undef malloc
  201.     #undef calloc
  202.     #undef free
  203.     
  204.     // Define data types for printf, scanf.
  205.     #if (MATLAB == 4)                        /* Version 4 */
  206.         typedef short int PRINTF_INT;        /* type of arguments to printf et al. */
  207.         typedef long double PRINTF_DOUBLE;
  208.         typedef short int SCANF_INT;        /* type of arguments to scanf et al. */
  209.         typedef double SCANF_DOUBLE;
  210.     #elif (MATLAB == 3)                        /* Version 3.5 */
  211.         typedef long int PRINTF_INT;        /* type of arguments to printf et al. */
  212.         typedef double PRINTF_DOUBLE;
  213.         typedef short int SCANF_INT;        /* type of arguments to scanf et al. */
  214.         typedef long double SCANF_DOUBLE;    
  215.     #endif
  216.     #ifdef THINK_C    /* Declare our own QuickDraw globals, allocated by MATLABMain.h */
  217.         extern THINK_C_QD mex_qd;
  218.         #define qd mex_qd
  219.     #else
  220.         #define mex_qd qd
  221.     #endif
  222.     #if defined(MAIN)                        /* Some old programs #define MAIN. */
  223.         #include "MATLABMain.h"                /* New programs just #include directly. */
  224.     #endif
  225. #else
  226.     typedef long int INT;
  227.     #if SHORT_DOUBLE_OK
  228.         typedef short double DOUBLE;/* not allowed by Standard C */
  229.     #endif
  230.     typedef int PRINTF_INT;            /* type of arguments to printf et al. */
  231.     typedef double PRINTF_DOUBLE;
  232.     typedef int SCANF_INT;            /* type of arguments to scanf et al. */
  233.     typedef double SCANF_DOUBLE;
  234.     #if SHORT_DOUBLE_OK
  235.         typedef struct {
  236.             char *name;
  237.             INT type;
  238.             INT m;
  239.             INT n;
  240.             DOUBLE *pr;
  241.             DOUBLE *pi;
  242.         } Matrix;
  243.     #endif
  244. #endif
  245.  
  246. /*  Standard C headers */
  247. #include <ctype.h>
  248. #include <float.h>
  249. #include <limits.h>
  250. #include <string.h>
  251. #include <time.h>
  252.  
  253. /*  Macintosh headers */
  254. /*
  255. The inclusion, above, of Quickdraw.h will result in the inclusion of MixedMode.h
  256. only if the Universal Headers are used, since the Universal Headers and the Mixed
  257. Mode Manager are both new, providing universal support for 68k and ppc Macs.
  258. */
  259. #if defined(__MIXEDMODE__)
  260.     #if defined(GENERATINGPOWERPC) || defined(GENERATING68K)
  261.         #define UNIVERSAL_HEADERS 2    /* version 2 */
  262.     #else
  263.         #define UNIVERSAL_HEADERS 1    /* version 1 */
  264.     #endif
  265. #else
  266.     #define UNIVERSAL_HEADERS 0
  267. #endif
  268. #if MAC_C
  269.     #if THINK_C
  270.         #include <console.h>
  271.     #endif
  272.     #include <Devices.h>
  273.     #include <Errors.h>
  274.     #include <Events.h>
  275.     #include <FixMath.h>    /*  Must come before mc68881.h */
  276.     #include <Fonts.h>
  277.     #include <GestaltEqu.h>
  278.     #include <Memory.h>
  279.     #include <OSEvents.h>
  280.     #include <OSUtils.h>    /*  required */
  281.     #include <Packages.h>
  282.     #include <Palettes.h>
  283.     #if THINK_C
  284.         #include <profile.h>/* only needed if you want timing info */
  285.     #endif
  286.     #include <QDOffscreen.h>
  287.     #include <Resources.h>
  288.     #include <Retrace.h>    /*  required */
  289.     #include <Slots.h>
  290.     #include <Sound.h>
  291.     #if !defined(THINK_C) || UNIVERSAL_HEADERS
  292.         #include <Strings.h>/* c2pstr() and p2cstr() */
  293.         #define CtoPstr c2pstr
  294.         #define PtoCstr p2cstr
  295.     #else
  296.         #include <pascal.h>    /* CtoPStr() and PtoCStr() */
  297.         #ifndef c2pstr
  298.             #define c2pstr(s) CtoPstr(s)
  299.             #define p2cstr(s) PtoCstr(s)
  300.         #endif
  301.     #endif
  302.     #include <Timer.h>        /*  required */
  303.     #include <ToolUtils.h>
  304.     #include <Video.h>
  305.     #include <Windows.h>    /*  required */
  306.     // Old Memory.h header files, before Apple's Universal Headers, don't define the new
  307.     // BlockMoveData(), so we do it here, to retain compability with the old header files.
  308.     #if !UNIVERSAL_HEADERS
  309.         #pragma parameter BlockMoveData(__A0,__A1,__D0)
  310.         extern pascal void BlockMoveData(const void *srcPtr,void *destPtr,Size byteCount)=0xA22E;
  311.     #endif
  312. #endif
  313.  
  314. /*
  315. This redefines the standard C functions, malloc, etc. to instead call Apple's
  316. corresponding routines, e.g. NewPtr. The THINK C memory management routines are 
  317. poor because they are bad about freeing space, tending to fragment the free space. 
  318. */
  319. #if THINK_C
  320.     #include "MacMemory.h"
  321. #endif
  322.  
  323. /*
  324. MATLAB AND THE NEWLINE CHARACTER
  325. In most C environments the newline character is '\n' (ascii 10). In Apple's
  326. wisdom they chose to separate lines in Macintosh files with the ascii 13
  327. character, which is usually called the return character '\r'. Standard C
  328. specifies that the stdio library will use '\n' as the newline character. This
  329. potentially creates a compatibility problem between Mac C programs and C
  330. programs written for the rest of the world's computers, since one wants any text
  331. files they produce to be appropriate to the local environment. Both MPW and
  332. THINK C resolve the problem behind the scenes, but they do it in different ways.
  333. MPW redefines the association between symbolic names and character codes, making
  334. '\n' be 13 and '\r' be 10. THINK C instead modifies the stdio library so that
  335. reads and writes to a "text" (i.e. not binary) stream are translated, exchanging
  336. character codes 10 and 13. Both solutions work. However, when we use THINK C to
  337. create code resources for MATLAB we are forced to use the MPW stdio library that
  338. is built into MATLAB. Unfortunately this bypasses both compilers' fixes to the
  339. newline problem. The problem affects every single text i/o operation, e.g. every
  340. printf and scanf. Alas, there is no way to get the pre-processor to redefine /n
  341. and /r.
  342.  
  343. We have attempted two solutions: a quick fix, using macros NL and NEWLINE, and a
  344. complete clean fix, using TranslateLinefeeds.c. At present only the quick fix
  345. works.
  346.  
  347. Our quick fix is to create a macro called NL that is normally defined as the
  348. newline string "\n", but which is instead defined as "\015" (i.e. ascii 13) when
  349. MATLAB is true. Programs such as Assign.c that have replaced all instances of
  350. "\n" by NL will then work whether or not MATLAB is true. The obvious drawback is
  351. that this quick solution requires these modifications to the source files.
  352.  
  353. The clean relatively complete solution is to insert a filter,
  354. TranslateLinefeeds.c, that intercepts the calls to the stdio library and
  355. translates /r to /n and vice versa for i/o to text files. The header file
  356. TranslateLinefeeds.h redefines all the stdio calls as macros that call
  357. corresponding routines within TranslateLinefeeds.c. Note that scanf is not
  358. intercepted and that for printf (and fprintf, ...) only the format string
  359. is translated; linefeeds hiding in char or string arguments in the variable
  360. part of the argument list are not be translated.
  361. */
  362. #if MATLAB && THINK_C            /* Clean, relatively complete solution */
  363.     //#include <TranslateLinefeeds.h>
  364. #endif
  365. #if !defined(_TranslateLinefeeds_) && MATLAB && THINK_C    /* Quick fix */
  366.     #define NL "\r"
  367.     #define NEWLINE '\r'
  368. #else
  369.     #define NL "\n"        /* the standard new-line string */
  370.     #define NEWLINE '\n'
  371. #endif
  372.  
  373. /*
  374. TRUE and FALSE
  375. */
  376. #ifndef TRUE
  377.     #define FALSE    0
  378.     #define TRUE    1
  379. #endif
  380.  
  381. /*
  382. NAN & INF
  383. If you're using NAN and INF you'll be interested in the IsNan(), IsInf(), and
  384. IsFinite() definitions & prototypes below. When compiling for a PowerPC, 
  385. math.h includes the fp.h header, which defines INFINITY and NAN.
  386. */
  387. #if !defined(INF)
  388.     #define INF HUGE_VAL    /* defined in math.h */
  389. #endif
  390. #if !defined(NAN) && !defined(powerc)
  391. //    #define NAN    (0.0/0.0)    /* evaluated at runtime */
  392.     #define NAN    Nan            /* global defined in Nan.c */
  393. #endif
  394.  
  395. /*
  396. NUMERICAL CONSTANTS
  397. It's sad to say, but THINK C 5.02 loses two bits of precision converting between
  398. doubles and ascii text, in either direction. Thus you will obtain more accurate
  399. results by computing the numerical constants below at runtime rather than using
  400. these predefined constants. The ANSI Numerical C Extensions group is moving to
  401. require C compilers to preserve precision, so there is hope for the future. Of
  402. course most applications would never notice a loss of two bits precision out of
  403. the total double precision given by the 64 bits in the mantissa.
  404. */
  405. #if !defined(PI)
  406.     #define PI        3.1415926535897932385    /* computed in Mathematica */
  407. #endif
  408. #if !defined(LOGPI)
  409.     #define LOGPI    1.14472988584940017414    /* computed in Mathematica */
  410. #endif
  411. #if !defined(LOG2)
  412.     #define LOG2    0.69314718055994530942    /* computed in Mathematica */
  413. #endif
  414. #if !defined(LOG10)
  415.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  416. #endif
  417.  
  418. #if MAC_C
  419.     /*
  420.     CLUTSIZE
  421.     Inline code that returns the same answer as GDClutSize(device).
  422.     */
  423.     #define GDCLUTSIZE(device) (gdClutSizeTable[(**(**(device)).gdPMap).pixelSize])
  424.     
  425.     /*  Commented out, because its answer is misleading when in 16-bit or 32-bit mode. */
  426.     /* #define GDCOLORS(device) ((**(**(**device).gdPMap).pmTable).ctSize+1) */
  427. #endif
  428.  
  429. /*
  430. FIXED POINT ARITHMETIC
  431. Apple defines a handy data type called Fixed that is stored in a long, but is
  432. assumed to have a decimal point in the middle. Many operations, e.g. adding two
  433. Fixed numbers or multiplying or dividing a Fixed by an integer, can be performed
  434. directly. To multiply or divide two Fixed numbers use Apple's FixMul() and
  435. FixDiv(). FixRatio(n,m) returns the Fixed ratio of two integers. Macintosh C
  436. compilers define double in various ways, depending on whether a floating point
  437. unit is to be used. The Apple-provided routines for doing type conversion to and
  438. from Fixed are only appropriate if you are NOT using the floating point unit.
  439. The ones defined below are faster and work with or without the FPU.
  440. */
  441. #define LongToFix(x) ((long)(x)<<16)
  442. #define FixToLong(x) ((x)>>16)
  443. #define DoubleToFix(x) ((long)((x)*65536.+0.5))
  444. #define FixToDouble(x) ((double)(x)*(1./65536.))
  445.  
  446. #if MAC_C
  447.     /*
  448.     STACK
  449.     StackGrow(n) increases the stack allocation by n bytes. You'll also want to use
  450.     Apple's StackSpace(), declared in Memory.h, that returns the number of bytes 
  451.     allocated for the stack.
  452.     */
  453.     #define StackGrow(extraBytes) SetApplLimit(GetApplLimit()-(extraBytes))
  454. #endif
  455.  
  456. /* Assign.c */
  457.  
  458. #define ASSIGN_DIMS 3        /* Feel free to increase or decrease ASSIGN_DIMS. */
  459. typedef struct {
  460.     short type;
  461.     unsigned sizedOnce:1;    /* dim[] is meaningful */
  462.     unsigned sized:1;        /* dim[] is final */
  463.     unsigned malloced:1;    /* allocated by malloc */
  464.     char *name;
  465.     void *ptr;                /* for array, address of element zero */
  466.     long dim[ASSIGN_DIMS];    /* zero indicates a scalar */
  467.     long firstElement;        /* for 1-d array, index of first array element. Usually 0 */
  468.     const char *comment;    /* text string, or NULL */
  469. } Description;
  470. enum{assignReportUnknown=1,assignNoHexInts=2,assignHexFloats=4
  471.     ,assignNoComment=8,assignNoPrintfExit=0x10
  472.     ,assignEchoAssignments=0x20,assignEchoComments=0x40,assignEchoFile=0x80
  473. };
  474. enum {assignMemoryError=-1,assignTypeError=-2
  475.     ,assignVariableError=-3,assignUnknownVariableError=-4
  476.     ,assignSubscriptError=-5,assignSubscriptBoundsError=-6
  477.     ,assignEqualsError=-7,assignConstantError=-8,assignHexError=-9
  478.     ,assignSemicolonError=-10,assignFileError=-11
  479.     ,assignInconsistentDescriptionsError=-12,assignUnequalDataError=-13
  480.     ,assignInconsistentDimensionsError=-14
  481.     ,assignCouldntFindDescription=-15
  482. };
  483. enum{charType=1,unsignedCharType,shortType,unsignedShortType
  484.     ,longType,unsignedLongType
  485.     ,floatType
  486.     #if SHORT_DOUBLE_OK
  487.         ,shortDoubleType
  488.     #endif
  489.     ,doubleType
  490.     ,charPtrType,unsignedCharPtrType,shortPtrType,unsignedShortPtrType
  491.     ,longPtrType,unsignedLongPtrType
  492.     ,floatPtrType
  493.     #if SHORT_DOUBLE_OK
  494.         ,shortDoublePtrType
  495.     #endif
  496.     ,doublePtrType
  497.     ,stringType,unknownType
  498. };
  499. FILE *OpenCalFileRead(char *filename);
  500. FILE *OpenCalFileReadAndCheck(char *filename);
  501. FILE *OpenCalFileWrite(char *filename);
  502. void AppendDescriptions(Description **d,Description *s);
  503. void CopyDescriptions(Description *d,Description *s);
  504. Description *AllocateDescriptions(long n);
  505. void FreeDescriptions(Description *d);
  506. long NumberOfDescriptions(Description *d);
  507. Description NullDescription(void);
  508. int IsNullDescription(Description d);
  509. #define IsNullDescription(d) ((d).type==0)
  510. int AssignmentLineWasBlank(void);
  511. int UnequalDescribedVars(Description d1[],Description d2[],short flags);
  512. int UnequalDescribedVarPair(Description *d1,Description *d2,short flags);
  513. int CopyDescribedVars(Description d1[],Description d2[],short flags);
  514. int CopyDescribedVarPair(Description *d1,Description *d2,short flags);
  515. long InitializeADescribedVar(Description *d,short flags);
  516. long InitializeDescribedVars(Description d[],short flags);
  517. long FindDescribedDim(Description d[],void *ptr,int i,short flags);
  518. long FindDescription(Description d[],void *ptr,short flags);
  519. void FreeADescribedVar(Description *d,short flags);
  520. void FreeDescribedPtrVars(Description d[],short flags);
  521. void FreeDescribedVars(Description d[],short flags);
  522. void KeepDescribedVars(Description d[],short flags);
  523. void KeepADescribedVar(Description *d,short flags);
  524. long PrintAnAssignment(FILE *stream,Description *d,short flags);
  525. long PrintAssignments(FILE *stream,Description d[],short flags);
  526. long PrintAssignmentsToFile(const char *filename,Description d[],short flags);
  527. long ReadAssignmentLine(FILE *stream,Description d[],short flags);
  528. long ReadAssignmentBlock(FILE *stream,Description d[],short flags);
  529. long ReadAssignmentStream(FILE *stream,Description d[],short flags);
  530. long ReadAssignmentFile(const char *filename,Description d[],short flags);
  531. Description Describe(short type,void *ptr,char *name,const char *comment);
  532. Description DescribeArray(short type,void *ptr,char *name,const char *comment,...);
  533. Description DescribeFirstLast(short type,void *ptr,char *name
  534.     ,const char *comment,long firstElement,long lastElement);
  535.  
  536. /* Binomial.c */
  537.  
  538. long    BinomialSample(double p,long n);
  539. int        BinomialSampleQuickly(int n);
  540. double    BinomialLowerBound(double P,long k,long n);
  541. double    BinomialUpperBound(double P,long k,long n);
  542. double    BinomialPdf(double p,long k,long n);
  543. double    Binomial(double p,long k,long n);
  544. double    IncompleteBeta(double x,double a,double b);
  545. double    InverseBinomial(double P,long k,long n);
  546. double    InverseIncompleteBeta(double p,double a,double b);
  547.  
  548. /* BreakLines.c */
  549.  
  550. char *BreakLines(char *string,long lineLength);
  551. void PrintWrappedText(FILE *stream,const char *s);
  552. void PrintWrappedTextToFile(const char *filename,const char *s);
  553. void PrintWrappedComment(FILE *stream,const char *s);
  554. void PrintWrappedCommentToFile(const char *filename,const char *s);
  555.  
  556. #if MAC_C
  557.     /* CardSlot.c */
  558.     
  559.     OSErr    CardSlot(char *cardName);
  560.     
  561.     /* CenterRectInRect.c */
  562.     
  563.     void    CenterRectInRect(Rect *moveableRectPtr,Rect *fixedRectPtr);
  564.     void    OffsetRectTile(Rect *r,int nx,int ny);
  565.     Boolean IsRectInRect(Rect *r,Rect *R);
  566.  
  567. #endif
  568.  
  569. /* ChiSquare.c */
  570.  
  571. double    PChiSquare (double chiSquare,int n);
  572.  
  573. /* Choose.c */
  574.  
  575. #if !MAC_C
  576.     #define Boolean unsigned char
  577. #endif
  578. int Choose(int defaultChoice,const char *query,char *choices[],int n);
  579. char *ChoiceStr(char *choices[],int n);
  580. int MultipleChoice(short defaultChoice,short n,char *choices[]);
  581. Boolean YesOrNo(Boolean defaultAnswer);
  582. extern char *noYes[];
  583. #if !MAC_C
  584.     #undef Boolean
  585. #endif
  586.  
  587. #if MAC_C
  588.     /* ChooseScreen.c */
  589.     
  590.     int ChooseScreen(int screen,const char *question);
  591.  
  592.     /* ConvolveX.c */
  593.     
  594.     void    ConvolveX(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
  595.                 Rect *srcRectPtr,Rect *dstRectPtr);
  596.  
  597.     /* ConvolveY.c */
  598.     
  599.     void ConvolveY(double f[],int dim,BitMap *srcBits,BitMap *dstBits,
  600.                 Rect *srcRectPtr,Rect *dstRectPtr);
  601.     
  602.     /* CopyBitsQuickly.c */
  603.     
  604.     enum{addOverQuickly=40,addOverParallel=40,mulOver};
  605.     int    CopyBitsQuickly(BitMap *srcBits,BitMap *dstBits
  606.         ,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
  607.     
  608.     /* CopyQuickDrawGlobals.c */
  609.     
  610.     void CopyQuickDrawGlobals(void);
  611.     #define CopyQuickdrawGlobals CopyQuickDrawGlobals    /*  old spelling */
  612.     
  613.     /* CopyWindows.c */
  614.     
  615.     enum{copyLiterally=0x10000,copyColorize=0x20000};
  616.     enum{srcCopyLiterally=srcCopy+copyLiterally,addOverLiterally=addOver+copyLiterally
  617.         ,addOverParallelLiterally=addOverParallel+copyLiterally
  618.         ,mulOverLiterally=mulOver+copyLiterally};
  619.     int CopyWindows(CWindowPtr srcWindow,CWindowPtr dstWindow
  620.         ,Rect *srcRectPtr,Rect *dstRectPtr,long srcMode,RgnHandle maskRgn);
  621.  
  622.     /* CreateTrialSnds.c */
  623.     
  624.     void CreateTrialSnds(void);
  625. #endif
  626.  
  627. /* DatedString.c */
  628.  
  629. char    *DatedString(unsigned long seconds);
  630.  
  631. #if MAC_C
  632.     /* DrawPrintf.c */
  633.     
  634.     void DrawPrintf(char *s, ...);
  635. #endif
  636.  
  637. /* Exponential.c */
  638.  
  639. double ExponentialPdf(double x);
  640.  
  641. /* ffprintf.c */
  642.  
  643. int ffprintf(FILE *stream[2],char *format,...);
  644.  
  645. #if MAC_C
  646.     /* FlushCacheRange.c */
  647.     
  648.     void FlushCacheRange (void *address, unsigned long count);
  649.     
  650.     /* fp.c */
  651.     
  652.     /* These 3 prototypes appear in Apple's fp.h, but only when it's compiled for */
  653.     /* the PowerPC, not for the 68k. Apple has promised to eventually make the routines */
  654.     /* available on both platforms. In the meantime the VideoToolbox provides the routines */
  655.     /* for 68k machines, so that your programs can use these functions without worrying */
  656.     /* about which platform you might run on. */
  657.     /* Apple's current header files define extended80 in <Types.h>. However, some older */
  658.     /* compilers may have old header files that only define extended80 in <SANE.h>. */
  659.     /* In that case, comment out any offending prototypes below, and paste them */
  660.     /* directly into your source files, after "#include <SANE.h>". The SANE.h header */
  661.     /* file has side effects, so you shouldn't include it here */
  662.     /* or in any file that doesn't really need it. Alternatively, instead of including */
  663.     /* all of SANE.h, you could just copy the definition of extended80. We can't do that */
  664.     /* here because it's an error to repeat a typedef. */
  665.  
  666.     #if !__powerc
  667.         void ldtox80(long double *x,extended80 *x80);
  668.         void x80told(extended80 *x80,long double *x);
  669.         long int fpclassify(double x);
  670.     #endif
  671.  
  672.     /* GDOpenWindow.c */
  673.     
  674.     void AddExplicitPalette(WindowPtr window);
  675.     void RemovePalette(WindowPtr window);
  676.     WindowPtr GDOpenWindow1(GDHandle device);
  677.     void GDDisposeWindow1(WindowPtr window);
  678.     CWindowPtr GDOpenWindow(GDHandle device);
  679.     void GDDisposeWindow(CWindowPtr myWindow);
  680.     void GDGrayColorTable(GDHandle device);
  681.     void SwapWindowExplicitMode(CWindowPtr window,Boolean *explicit);
  682.     BitMap *GetBitMapPtr(CWindowPtr window);
  683.     Boolean IsGWorldPtr(CWindowPtr window);
  684.     Boolean IsGrafPtr(CWindowPtr window);
  685.     
  686.     /* GDPrintf.c */
  687.     
  688.     void GDPrintf(char *s, ...);
  689.     
  690.     /* GDTime.c */
  691.     
  692.     double GDFrameRate(GDHandle device);
  693.     double GDMovieRate(GDHandle device,int quickly);
  694.     double GDMovieSize(GDHandle device,int quickly);
  695.     double GDVBLRate(GDHandle device);
  696.     double TickRate(void);
  697.     typedef OSErr (*SetEntriesFunction)(GDHandle device,short start,short count
  698.         ,ColorSpec *aTable);
  699.     OSErr GDTimeClut(GDHandle device,SetEntriesFunction function,short clutEntries
  700.         ,double *sPtr,double *framesPtr,double *missingFramesPtr,double *frameRatePtr);
  701.     
  702.     /* GDVideo.c */
  703.     
  704.     #define MAX_SCREENS 8
  705.     char  *GDCardName(GDHandle device);
  706.     extern short gdClutSizeTable[33];
  707.     short GDClutSize(GDHandle device);
  708.     long GDColors(GDHandle device);
  709.     OSErr GDControl(int refNum,int csCode,Ptr csParamPtr);
  710.     short GDDacSize(GDHandle device);
  711.     OSErr GDDirectSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  712.     OSErr GDGetDisplayMode(GDHandle device,unsigned long *displayModeIDPtr
  713.         ,unsigned short *modePtr,unsigned short *pagePtr,Ptr *baseAddrPtr);
  714.     OSErr GDGetNextResolution(GDHandle device,unsigned long previousDisplayModeID
  715.         ,unsigned long *displayModeIDPtr,unsigned long *horizontalPixelsPtr
  716.         ,unsigned long *verticalLinesPtr,Fixed *refreshRatePtr
  717.         ,unsigned short *maxDepthModePtr);
  718.     OSErr GDGetDefaultGamma(GDHandle device,GammaTbl **gammaTbl);
  719.     OSErr GDGetDefaultMode(GDHandle device,short *modePtr);
  720.     OSErr GDGetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  721.     OSErr GDGetGamma(GDHandle device,GammaTbl **myGammaTblHandle);
  722.     OSErr GDGetGray(GDHandle device,Boolean *flagPtr);
  723.     OSErr GDGetInterrupt(GDHandle device,Boolean *flagPtr);
  724.     OSErr GDGetMode(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
  725.     OSErr GDGetPageBase(GDHandle device,short page,Ptr *baseAddrPtr);
  726.     OSErr GDGetPageCnt(GDHandle device,short mode,short *pagesPtr);
  727.     OSErr GDGrayPage(GDHandle device,short page);
  728.     Boolean GDHasMode(GDHandle device,short mode,short *pixelSizePtr,short *pagesPtr);
  729.     short GDModePixelSize(GDHandle device,short mode);
  730.     unsigned char *GDName(GDHandle device);
  731.     char *GDNameStr(GDHandle device);
  732.     ColorSpec *GDNewLinearColorTable(GDHandle device);
  733.     short GDPixelSize(GDHandle device);
  734.     OSErr GDPrintGammaTable(FILE *o,GDHandle device);
  735.     OSErr GDReset(GDHandle device,short *modePtr,short *pagePtr,Ptr *baseAddrPtr);
  736.     OSErr GDRestoreDeviceClut(GDHandle device);
  737.     OSErr GDRestoreGamma(GDHandle device);
  738.     OSErr GDSaveGamma(GDHandle device);
  739.     OSErr GDSetDefaultMode(GDHandle device,short mode);
  740.     OSErr GDSetEntries(GDHandle device,short start,short count,ColorSpec *aTable);
  741.     OSErr GDSetEntriesByType(GDHandle device,short start,short count,ColorSpec *table);
  742.     OSErr GDSetEntriesByTypeHighPriority(GDHandle device,short start,short count
  743.         ,ColorSpec *table);
  744.     OSErr GDSetGamma(GDHandle device,GammaTbl *myGammaTblPtr);
  745.     OSErr GDSetGray(GDHandle device,Boolean flag);
  746.     OSErr GDSetInterrupt(GDHandle device,Boolean flag);
  747.     OSErr GDSetMode(GDHandle device,short mode,short page,Ptr *baseAddrPtr);
  748.     OSErr GDSetPageDrawn(GDHandle device,short page);
  749.     OSErr GDSetPageShown(GDHandle device,short page);
  750.     OSErr GDStatus(int refNum,int csCode,Ptr csParamPtr);
  751.     short GDType(GDHandle device);
  752.     OSErr GDUncorrectedGamma(GDHandle device);
  753.     int  GDVersion(GDHandle device);
  754.     int  PatchMacIIciVideoDriver(void);
  755.     
  756.     /* GetClicks.c */
  757.     
  758.     short    GetClicks(void);
  759.  
  760.     /* GetScreenDevice.c */
  761.     
  762.     GDHandle    GetScreenDevice(int n);
  763.     int            GetScreenIndex(GDHandle device);
  764.     GDHandle    SlotToScreenDevice(int n);
  765.     GDHandle    GetDeviceByRefNum(int n);
  766.     short int    GetDeviceSlot(GDHandle device);
  767.     GDHandle    GetWindowDevice(WindowPtr theWindow);
  768.     GDHandle    GetRectDevice(Rect *r);
  769.     void        LocalToGlobalRect(Rect *r);
  770.     void        GlobalToLocalRect(Rect *r);
  771.  
  772. #endif
  773.  
  774. /* GetTimeDateString.c */
  775.  
  776. char *GetTimeDateString(time_t t);
  777.  
  778. #if MAC_C
  779.     /* GetVersionString.c */
  780.  
  781.     char *GetVersionString(void);
  782.  
  783.     /* GetVoltage.c */
  784.     
  785.     double    VoltsDuringFrame(double frames);
  786.     double    GetVoltage(short channel,double *gainPtr,double *frequencyPtr,long n
  787.                 ,double *sdPtr);
  788.     short    GetVoltages(short channel,double *gainPtr,double *frequencyPtr,long *nPtr
  789.                 ,unsigned short readings[],double *voltDeltaPtr,double *voltZeroPtr);
  790.     short    InitiateVoltageSampling(short channel,double *gainPtr,double *frequencyPtr
  791.                 ,double *voltDeltaPtr,double *voltZeroPtr);
  792.     short    RetrieveVoltages(long *nPtr,unsigned short readings[]);
  793.     int        ForeRunnerSlot(void);
  794.     enum{voltageBufferOverflow=1<<0,voltageOverflow=1<<1,voltageUnderflow=1<<2};
  795. #endif
  796.  
  797. /* HexToBinary.c */
  798.  
  799. int HexToBinary(char *string,void *ptr);
  800. char *BinaryToHex(size_t n,void *ptr,char *string);
  801.  
  802. #if MAC_C
  803.     /* HideMenuBar.c */
  804.     
  805.     void    HideMenuBar(void);
  806.     void    ShowMenuBar(void);
  807.     void SquareCorners(GDHandle device);
  808.     void RestoreCorners(GDHandle device);
  809.     void UnclipScreen(GDHandle device);
  810.     void RestoreScreenClipping(GDHandle device);
  811.     
  812.     /* Identify.c */
  813.     
  814.     char *IdentifyApplication(void);
  815.     char *IdentifyCompiler(void);
  816.     char *IdentifyMachine(void);
  817.     char *IdentifyModel(void);
  818.     char *IdentifyOwner(void);
  819.     char *IdentifyVideo(GDHandle device);
  820.     
  821.     /* ImageStatistics */
  822.  
  823.     double ImageEnergy(GWorldPtr aWorld,Rect *aRect,double background);
  824.     void ImageStatistics(GWorldPtr world,Rect *rect
  825.         ,long *minPtr,long *maxPtr,double *meanPtr,double *meanSquarePtr);
  826.  
  827.     /* IsCmdPeriod.c */
  828.     
  829.     Boolean IsCmdPeriod(EventRecord *event);
  830. #endif
  831.  
  832. /* IsNan.c */
  833.  
  834. int IsNan(double x);
  835. int IsInf(double x);
  836. #ifndef IsFinite    /* neither NAN nor ±INF */
  837.     #define IsFinite(x) \
  838.     (sizeof(x)>8?    \
  839.     ((*(short *)&(x) & 0x7FFF)!=0x7FFF)        /* 10 or 12 byte double */\
  840.     :((*(short *)&(x) & 0x7FF0)!=0x7FF0))    /* 8 byte double */
  841. #endif
  842.  
  843. #if MAC_C
  844.     /* kbhit.c */
  845.     
  846.     int    kbhit(void);
  847.     int    getcharUnbuffered(void);
  848. #endif
  849.  
  850. /* Log2L.c */
  851.  
  852. long Log2L(unsigned long j);
  853.  
  854. #if MAC_C
  855.     
  856.     /* MaximizeConsoleHeight.c */
  857.     
  858.     void MaximizeConsoleHeight(void);
  859. #endif
  860.  
  861. /* Mean.c */
  862.  
  863. double Mean(double x[],long n,double *sdPtr);
  864. double MeanF(float x[],long n,double *sdPtr);
  865. double MeanB(char x[],long n,double *sdPtr);
  866. double MeanUB(unsigned char x[],long n,double *sdPtr);
  867. double MeanW(short x[],long n,double *sdPtr);
  868. double MeanUW(unsigned short x[],long n,double *sdPtr);
  869. double MeanL(long x[],long n,double *sdPtr);
  870. double MeanUL(unsigned long x[],long n,double *sdPtr);
  871.  
  872. /* Nan.c */
  873. extern const short __NAN[];
  874. #define Nan (*(double *)__NAN)
  875.  
  876. #if MAC_C
  877.     /* NoiseFill.c */
  878.     
  879.     int NoiseFill(CWindowPtr window,Rect *r,double dx,double dy,Boolean randomPhase);
  880.     int NoiseFillBits(PixMap *bits,Rect *r,double dx,double dy,Boolean randomPhase);
  881.     int MakeNoise1(double dx,double dy,Boolean randomPhase,PixMap *bits);    /* Obsolete */
  882.     
  883.     /* NoisePdfFill.c */
  884.     
  885.     OSErr NoisePdfFill(GWorldPtr world,Rect *rectPtr
  886.         ,int pdf,double *meanPtr,double *sdPtr,int min,int max);
  887.     OSErr NoisePdfAdd(GWorldPtr world,Rect *rectPtr
  888.         ,int pdf,double *meanPtr,double *sdPtr,int min,int max);
  889.     enum{kBinaryPdf=0,kBinomialPdf,kGaussianPdf,kUniformPdf};
  890. #endif
  891.  
  892. /* Normal.c */
  893.  
  894. double NormalPdf(double x);
  895. double Normal(double x);
  896. double InverseNormal(double p);
  897. double NormalSample(void);
  898. double Normal2DPdf(double r);
  899. double Normal2D(double r);
  900. double InverseNormal2D(double p);
  901. double Normal2DSample(void);
  902. double InverseNormal2DPdf(double p);
  903. void BoundedNormalIntegers(short *distribution,long n,double mean,double sd
  904.     ,short min,short max);
  905.  
  906. /* nrand.c */
  907.  
  908. unsigned long nrand(unsigned long n);
  909.  
  910. /* OpenDataFiles.c */
  911.  
  912. unsigned long OpenDataFiles(FILE **inPtr,FILE **outPtr
  913.                     ,char *inName,char *outName);
  914.  
  915. /* OpenPreferencesFolder.c */
  916.  
  917. #if !MAC_C
  918.     #define OSErr short
  919. #endif
  920. OSErr OpenPreferencesFolder(void);
  921. OSErr ClosePreferencesFolder(void);
  922. OSErr OpenPreferencesWD(short *wdRefNumPtr);
  923. #if !MAC_C
  924.     #undef OSErr
  925. #endif
  926.  
  927. #if MAC_C
  928.     /*    PixMapToPICT.c */
  929.  
  930.     void PixMapToPICT(char *filename,PixMap **pm,Rect *rectPtr
  931.         ,int pixelSize,ColorTable **cTable);
  932.  
  933.     /*    PixMapToPostScript.c */
  934.     
  935.     void WindowToEPS(CWindowPtr window,char *filename,Rect *rectPtr
  936.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels,float reflectance[256]);
  937.     void PixMapToEPS(char *filename,PixMap **pm,Rect *rectPtr
  938.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
  939.     void PixMapToPostScript(char *filename,PixMap **pm,Rect *rectPtr
  940.         ,Rect *pageRectPtr,double cellsPerInch,int grayLevels);
  941.     void AppendToFile(char *filename,char *string);
  942.     
  943.     /* PlotXY.c */
  944.     
  945.     typedef struct{
  946.         Boolean continuing;    /* zero to start a new curve */
  947.         long color;            /* e.g. blackColor, blueColor */
  948.         short lineWidth;    /* in pixels, zero for none */
  949.         short symbolWidth;    /* in pixels, zero for none */
  950.         short dashOffset;    /* in pixels */
  951.         short dash[5];        /* in pixels. The array is terminated by a zero element */
  952.         short h,v;            /* reserved for internal use */
  953.         Fixed pathLengthF;    /* reserved for internal use */
  954.     } PlotXYStyle;
  955.     void PlotXY(WindowPtr window,double x,double y,PlotXYStyle *style);
  956. #endif
  957.  
  958. /* PrintfExit.c */
  959.  
  960. int PrintfExit(const char *format,...);
  961.  
  962. #if MAC_C
  963.  
  964.     /* PrintfGWorld.c */
  965.  
  966.     void PrintfGWorld(GWorldPtr our);
  967.     void PrintStringAsBitmap(unsigned char *s);
  968.  
  969.     /* QD32Exists.c */
  970.     
  971.     Boolean         QD8Exists(void);
  972.     Boolean            QD32Exists(void);
  973.     Boolean            NewPaletteManager(void);
  974. #endif
  975.  
  976. /* randU.c */
  977.  
  978. unsigned short    randU(void);
  979. unsigned long    randUL(void);
  980. void            srandU(unsigned n);
  981. void            RandFill(void *address,long bytes);
  982.  
  983. /* ReadMATLABFile.c */
  984.  
  985. int LoadNamedMatIntoDoubles(FILE *f,const char *name,long *rows,long *cols
  986.     ,double **real,double **imag);
  987. int LoadNamedMatIntoShorts(FILE *f,const char *name,long *rows,long *cols
  988.     ,short **real,short **imag);
  989. int LoadNextMatIntoDoubles(FILE *f,char *name,long *rows,long *cols
  990.     ,double **real,double **imag);
  991. int LoadNextMatIntoShorts(FILE *f,char *name,long *rows,long *cols
  992.     ,short **real,short **imag);
  993. int SaveMatDoubles(FILE *f,char *name,long rows,long cols,double *real,double *imag);
  994. int SaveMatShorts(FILE *f,char *name,long rows,long cols,short *real,short *imag);
  995.  
  996. #if MAC_C
  997.     /* RectToAddress.c */
  998.     
  999.     unsigned char *RectToAddress(PixMap *pixMapPtr,Rect *rectPtr,short *rowBytesPtr, 
  1000.         short *pixelSizePtr,short *bitsOffsetPtr);
  1001.     Ptr GetPixBaseAddr32(PixMap **pm);
  1002. #endif
  1003.     
  1004. /*    Require.c    */
  1005.  
  1006. void Require(long quickDrawVersion);
  1007. struct PrecompileSizeofInt{
  1008.     int i;
  1009. };
  1010. struct PrecompileSizeofDouble{
  1011.     double d;
  1012. };
  1013.  
  1014. #if MAC_C
  1015.     /* RestoreCluts.c */
  1016.     
  1017.     void RestoreCluts(void);
  1018.     
  1019.     /*    SetEntriesQuickly.c */
  1020.     
  1021.     OSErr SetEntriesQuickly(GDHandle device,short start,short count,ColorSpec *table);
  1022.     short macltset(GDHandle device,register short start
  1023.         ,unsigned short *red,unsigned short *green,unsigned short *blue,short count1);
  1024.     short GetCardType(GDHandle device);
  1025.     char *GetCardBase(GDHandle device);
  1026.     OSErr WaitForNextBlanking(GDHandle device);
  1027.     
  1028.     /* SetFileInfo.c */
  1029.     
  1030.     void    SetFileInfo(char *fileName,OSType fileType,OSType fileCreator);
  1031.     
  1032.     /* SetMouse.c */
  1033.     
  1034.     void    SetMouse(Point where);
  1035.     
  1036.     /* SetOnePixel.c */
  1037.     
  1038.     void SetPixmapPixel(PixMap *pmHandle,int x,int y,unsigned long value);
  1039.     unsigned long GetPixmapPixel(PixMap *pmHandle,int x,int y);
  1040.     unsigned char *GetPixmapPixelAddress(PixMap *pmHandle,int x,int y);
  1041.     void SetDevicePixel(GDHandle device,int x,int y,unsigned long value);
  1042.     unsigned long GetDevicePixel(GDHandle device,int x,int y);
  1043.     void SetOnePixel(int x,int y,unsigned long value);
  1044.     unsigned long GetOnePixel(int x,int y);
  1045.     #define SetIPixel SetDevicePixel    /*  So that old programs won't break. */
  1046.     #define GetIPixel GetDevicePixel    /*  So that old programs won't break. */
  1047.     
  1048.     /* SetPixelsQuickly.c */
  1049.     
  1050.     int SetPixelsQuickly(int x,int y,unsigned long value[],short n);
  1051.     int GetPixelsQuickly(int x,int y,unsigned long value[],short n);
  1052.     int SetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
  1053.     int GetWindowPixelsQuickly(WindowPtr window,int x,int y,unsigned long value[],short n);
  1054.     int SetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
  1055.     int GetDevicePixelsQuickly(GDHandle device,int x,int y,unsigned long value[],short n);
  1056.     int SetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
  1057.     int GetPixmapPixelsQuickly(PixMapPtr pmPtr,int x,int y,unsigned long value[],short n);
  1058.     
  1059.     /* SetPriority.c */
  1060.     
  1061.     void SwapPriority(char *priority);
  1062.     void SetPriority(int i);
  1063.     int GetPriority(void);
  1064. #endif
  1065.  
  1066. /* Shuffle.c */
  1067.  
  1068. void Shuffle(void *array,long elements,size_t elementSize);
  1069.  
  1070. #if MAC_C
  1071.     /* SndPlay1.c */
  1072.     
  1073.     OSErr SndPlay1(Handle snd);
  1074.     void SndStop1(void);
  1075.     short SndDone1(void);
  1076.  
  1077.     /* StringToDateAndSecs.c */
  1078.     
  1079.     double StringToDateAndSecs(char *string,DateTimeRec *date);
  1080.  
  1081.     /* StringBounds.c */
  1082.     
  1083.     void CharBounds(char a,Rect *bounds,long *count);
  1084.     void StrBounds(char *s,Rect *bounds,long *count);
  1085.     double StrOutlineLength(char *s);
  1086.     void StringBounds(const unsigned char *s,Rect *bounds,long *count);
  1087.     double StringOutlineLength(const unsigned char *s);
  1088.  
  1089.     /* Timer.c */
  1090.     
  1091.     struct Timer{
  1092.         TMTask time;
  1093.         long ourA5;
  1094.         long interval,elapsed,elapsedIntervals;
  1095.         long timeToStartTimer;            /*  minimum time in µs */
  1096.         long stopDelay;                    /*  µs from call to stop, re from call to start */
  1097.         long timeManagerVersion;
  1098.         struct Timer *next,*previous;    /*  doubly linked list of Timers */
  1099.     };
  1100.     typedef struct Timer Timer;
  1101.     
  1102.     Timer *NewTimer(void);
  1103.     void DisposeTimer(Timer *t);
  1104.     void StartTimer(Timer *t);
  1105.     long StopTimer(Timer *t);                    /*  µs */
  1106.     double StopTimerSecs(Timer *t);                /*  s */
  1107.     long PeekTimer(Timer *t);                    /*  µs */
  1108.     double PeekTimerSecs(Timer *t);                /*  s */
  1109.     
  1110.     /* TitleBarHeight.c */
  1111.     
  1112.     int TitleBarHeight(WindowPtr window);
  1113.     
  1114.     /* TrapAvailable.c */
  1115.     
  1116.     Boolean    TrapAvailable(short theTrap);
  1117. #endif
  1118.  
  1119. /* Uniform.c */
  1120.  
  1121. double UniformSample(void);
  1122.  
  1123. #if MAC_C
  1124.     /* VBLInstall.c */
  1125.     
  1126.     struct VBLTaskAndA5 {
  1127.         volatile VBLTask vbl;
  1128.         long ourA5;
  1129.         #if USESROUTINEDESCRIPTORS || GENERATINGCFM
  1130.             UniversalProcPtr subroutine;
  1131.         #else
  1132.             void (*subroutine)(struct VBLTaskAndA5 *vblData);
  1133.         #endif
  1134.         GDHandle device;
  1135.         long slot;
  1136.         volatile long newFrame;        /* Boolean */
  1137.         volatile long frame;        /* count up from zero */
  1138.         volatile long framesLeft;    /* count down to zero */
  1139.         long framesDesired;
  1140.         Timer *frameTimer;            /* time ms since last VBL interrupt, see Timer.c */
  1141.         void *ptr;                    /* use this for whatever you want */
  1142.     };
  1143.     typedef struct VBLTaskAndA5 VBLTaskAndA5;    
  1144.     OSErr VBLInstall(VBLTaskAndA5 *vblData,GDHandle device,long frames);
  1145.     OSErr VBLRemove(VBLTaskAndA5 *vblData);
  1146.     void SimpleVBLSubroutine(VBLTaskAndA5 *vblData);
  1147.     
  1148.     /* VideoTFB.c */
  1149.     
  1150.     Boolean TFBInSlot(int slot);
  1151.     void    SetUpTFB(int slot);
  1152.     void    RampClutTFB(int slot);
  1153.     void    GrayClutTFB(int slot);
  1154.     void    LoadClutTFB(int slot,unsigned char rgb[256][3]);
  1155.     void    NewBlankingTFB(int slot);
  1156.     void    NewFieldTFB(int slot);
  1157.     int        BlankingTFB(int slot);
  1158.     void    SetDepthTFB(int slot,short int bits);
  1159.     void    SynchSetDepthTFB(int masterSlot,int slot,short int bits);
  1160.     void    SynchToMainDeviceTFB(GDHandle device);
  1161.     void    HaltTFB(int slot);
  1162.     void    RestartTFB(int slot,short int bits);
  1163.     void    HaltDeviceTFB(GDHandle device);
  1164.     void    RestartDeviceTFB(GDHandle device);
  1165.     void    ScrollTFB(int slot,short int bits,long x,long y);
  1166.     void    PanTFB(int slot,long int x);
  1167. #endif
  1168.  
  1169. /* VLambda.c */
  1170.  
  1171. double VLambda(double nm);
  1172. double VLambdaPrime(double nm);
  1173.  
  1174. #if MAC_C
  1175.     /* Zoom.c */
  1176.     
  1177.     void Zoom(WindowPtr theWindow,int zoomDir,EventRecord *event);
  1178. #endif
  1179.  
  1180. #endif /* _VIDEOTOOLBOX_ */
  1181.